#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

//number of iterations
#define N 100000

int main()
{
    int i;
    int counter;
    double x, y;

    srand(time(NULL));
    counter = 0;

    for(i = 0 ; i < N; i++)
    {
        //generates an random (x,y) point
        x = (double)rand() / (double)RAND_MAX;
        y = (double)rand() / (double)RAND_MAX;

        //verify if point's position is inside the circle
        if(x*x+y*y <= 1) counter++;

        //pi's estimate  = 4*(inner points)/(total number of points)
        printf("%lf\n", 4*(double)counter/(double)N);
    }

    return 0;
}
